import {Color, MeshStandardMaterial} from "three";

const materialMap = {
    default: {
        label: '默认',
        material: null
    },
    baseColor: {
        label: '基础色',
        material: null
    },
    metalness: {
        label: '金属度',
        material: null
    },
    roughness: {
        label: '粗糙度',
        material: null
    },
    emissive: {
        label: '发光',
        material: null
    }
}
export const materialList = Object.keys(materialMap).map(key => ({label: materialMap[key].label, value: key}))
export const createMaterial = defaultMaterial => {
    for (const key in materialMap) {
        console.log(key)
        switch (key) {
            case 'default':
                materialMap[key].material = defaultMaterial
                break
            case 'metalness':
                materialMap[key].material = new MeshStandardMaterial({
                    ...defaultMaterial,
                    metalness: 1,
                    roughness: 0
                })
                break
            case 'roughness':
                materialMap[key].material = new MeshStandardMaterial({
                    ...defaultMaterial,
                    metalness: 0,
                    roughness: 1
                })
                break
            case 'baseColor':
                materialMap[key].material = new MeshStandardMaterial({
                    ...defaultMaterial,
                    metalness: 0,
                    roughness: 0
                })
                break
            case 'emissive':
                materialMap[key].material = new MeshStandardMaterial({
                    ...defaultMaterial,
                    metalness: 0,
                    roughness: 0,
                    emissive: new Color("blue")
                })
                break
        }
    }
}

export const getMaterial = mode => {
    return materialMap[mode]
}
